﻿#include "ReaderManager.h"


void ReaderManager::addReader(Reader* reader)
{
	m_readers.append(reader);
}

Reader* ReaderManager::findReaderByNo(const QString& readerno)
{
	for (auto reader : m_readers)
	{
		if (readerno == reader->m_readerNo)
		{
			return reader;
		}
	}

	return NULL;
}

Reader* ReaderManager::findReaderByName(const QString& readername)
{
	for (auto reader : m_readers)
	{
		if (readername == reader->m_readerName)
		{
			return reader;
		}
	}

	return NULL;
}

Reader* ReaderManager::findReaderBydept(const QString& readerdept)
{
	for (auto reader : m_readers)
	{
		if (readerdept == reader->m_dept)
		{
			return reader;
		}
	}

	return NULL;
}

Reader* ReaderManager::findReaderBytel(const int& readertel)
{
	for (auto reader : m_readers)
	{
		if (readertel == reader->m_tel)
		{
			return reader;
		}
	}

	return NULL;
}

ReaderManager* ReaderManager::instance()
{
	static ReaderManager* ins = nullptr;
	//如果类对象一个没有，才构造一个对象；	如果已经有一个类对象了，就不能再多构造出来了：
	return ins = (ins ? ins : new ReaderManager);
}